{% set per_page_size = 22 %}
{% set td_style = "border-right:1px solid #eeeeee;" %}
{% set page_count = [1] %}
<style type="text/css">
.breakpage { page-break-after:always;}
</style>
{% for user_name, userCustomers in all_customer.iteritems() %}
    {% set out_loop = loop %}
    {% for customer in userCustomers %}
         {% if loop.index%2==1 %}
          {% set td_top_color = 'border-top:1px solid #55555;' %}
          {% set td_left_color = 'border-left:1px solid #55555;' %}
        {% endif %}

         {% if loop.index%per_page_size == 1 %}
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
         {% endif %}
         {% if loop.index%2==1 %}
            <tr>
         {% endif %}
          <td style="{{td_left_color}}{{td_style}}border-bottom:1px solid #eeeeee;padding-top:0px;{{td_top_color}} padding-bottom:0px;height: 90px">
              &nbsp;<span style="padding-left: 5px;">{{customer.zip|default('',True)}}</span><br />
              &nbsp;<font style="font-family:STSong,宋体;font-size: 14px">
                  {% if customer.address %}
                    {{customer.address}}
                  {% endif %}
              </font>
            <br />
            <h5 style="margin-top:3px; margin-bottom:0px;font-family:STHeiti,微软雅黑,黑体;font-size: 15px;">&nbsp;&nbsp;
              {{customer.name|default('',True)}}</h5>
            <nobr><span style="margin-top:0px; margin-bottom:0px;font-family:楷体_GB2312,STKaiti,华文楷体;font-size: 16px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
              {{customer.department|default('',True)}} {{customer.linkname|default('',True)}} (收)</span>
            </nobr>
            <span style="color:#eeeeee; font-size: 8px; float: right">XS</span>
        </td>

         {% if loop.index%2==0 or loop.index == loop.length%}
            </tr>
         {% endif %}

         {% if loop.index%per_page_size==0 or loop.index==loop.length%}
             <tr><td colspan="2" align="right">第{{ page_count[0]}}页({{ user_name }})</td></tr>
             </table>
            {% if page_count.append(page_count.pop() + 1) %}{% endif %}
           <br />
            <div class="breakpage"></div>
         {% endif %}
    {% endfor %}
{% endfor %}
</div>